package com.ge.pp;

import java.awt.image.BufferedImage;
import java.util.Vector;


public class ImageFilter {
	public String name;
	public Vector<FilterAttribute> attributes;
	public PicturePane picturePane;
	
	public ImageFilter(PicturePane p) {
		name = "Generic";
		attributes = null;
		picturePane = p;
	}
	
	public Vector<FilterAttribute> getAttributes() {
		return attributes;
	}
	
	public void setAttribute(String attr, float val) throws Exception {
		try
		{
		for(FilterAttribute fa: attributes) {
			if (fa.name.equals(attr)) {
				if (val >= fa.min && val <= fa.max) {
					fa.val= val;
				}
			}
		}
		}
		catch(Exception e)
		{
			throw e;
		}
	}
	public FilterAttribute getAttribute(String attr) throws Exception {
		try
		{
			FilterAttribute fa = null;
		for(FilterAttribute fattr: attributes) {
			if (fattr.name.equals(attr)) {
				fa = fattr;
			}
		}
		return fa;
		}
		catch(Exception e)
		{
			throw e;
		}
	}
	
	public BufferedImage filter(BufferedImage in) throws Exception {
		return in;
	}

	public void refresh() {
		picturePane.repaint();		
	}
}